/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
//		File Name		:		MathLib.h
//
//		Author			:		Kevin Jordan
//
//		Purpose			:		To encapsulate some useful math functions
//
//		Dates			:		Written( Feb 9, 2011 ) by Kevin Jordan		LastUpdate( Feb 15, 2011  ) by Kevin Jordan 
//	
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#include "MathLib.h"
#include <ctime>


VIN_Vector2D::VIN_Vector2D()
{
	m_fX = 0;
	m_fY = 0;
}

VIN_Vector2D::VIN_Vector2D( float fX, float fY)
{

	m_fX = fX;
	m_fY = fY;
}


VIN_Vector2D::~VIN_Vector2D()
{



}


VIN_Vector2D VIN_Vector2D::operator+(const VIN_Vector2D& Vec1)
{
	VIN_Vector2D ret;
	ret.m_fX = m_fX + Vec1.m_fX;
	ret.m_fY = m_fY  + Vec1.m_fY;

	return ret;
}



VIN_Vector2D VIN_Vector2D::operator-(const VIN_Vector2D& Vec1)
{
	VIN_Vector2D ret;
	ret.m_fX = m_fX - Vec1.m_fX;
	ret.m_fY = m_fY  - Vec1.m_fY;

	return ret;
}

float absolute(float value)
{
	if(value >= 0)
		return value;
	else
		return -(value);
}


VIN_Vector2D VIN_Vector2D::operator*(int Multiplier)
{
	VIN_Vector2D ret;
	ret.m_fX =	m_fX * Multiplier;
	ret.m_fY =	m_fY * Multiplier;
	return ret;
}

VIN_Vector2D VIN_Vector2D::operator/(float f)
{
	VIN_Vector2D ret;
	ret.m_fX = m_fX / f;
	ret.m_fY = m_fY / f;
	return ret;
}


float VIN_Vector2D::LengthOfVector(VIN_Vector2D vec)
{
	float Length = sqrt( (vec.m_fX * vec.m_fX) + (vec.m_fY * vec.m_fY));
	return Length;


}

float VIN_Vector2D::DotProduct(VIN_Vector2D v1, VIN_Vector2D v2)
{
	float Dot = ( v1.m_fX * v2.m_fX) + (v1.m_fY * v2.m_fY);
	return Dot;

}

VIN_Vector2D VIN_Vector2D::NormalizeVector()
{
	VIN_Vector2D temp(m_fX, m_fY);
	float Length = LengthOfVector(temp);
	VIN_Vector2D Normalized = temp / Length;
	return Normalized;


}



bool IsEven(int Num)
{

	if( (Num & 1) == 0 )
	{
		return true;
	}

	return false;
}


int RandInt( int RangeLow, int RangeHigh)
{
	srand( unsigned int(time(0)));

	int RandomNum = rand() % ((RangeHigh - RangeLow) + 1 );
	return RandomNum;
}

